home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr47 / ucrasm27.zip / SOURCE.ZIP / PEEKCUR.ASM < prev    next >
Assembly Source File  |  1992-03-13  |  2KB  |  95 lines

  1.  
  2. ; Need to include "lists.a" in order to get list structure definition.
  3.  
  4.         include    lists.a
  5.  
  6.  
  7. wp        equ    <word ptr>        ;I'm a lazy typist
  8.  
  9.  
  10. ; Special case to handle MASM 6.0 vs. all other assemblers:
  11. ; If not MASM 5.1 or MASM 6.0, set the version to 5.00:
  12.  
  13.         ifndef    @version
  14. @version    equ    500
  15.         endif
  16.  
  17.  
  18.  
  19. StdGrp        group    stdlib,stddata
  20. stddata        segment    para public 'sldata'
  21. stddata        ends
  22.  
  23. stdlib        segment    para public 'slcode'
  24.         assume    cs:stdgrp
  25.  
  26. ; sl_PeekCur -    ES:DI points at a list.
  27. ;        Returns a pointer to the CurrentNode in the list in DX:SI.
  28. ;        Returns the carry flag set if the list was empty.
  29. ;
  30. ; Randall Hyde  3/13/92
  31. ;
  32.  
  33.         public    sl_PeekCur
  34. sl_PeekCur    proc    far
  35.  
  36.         if    @version ge 600
  37.  
  38. ; MASM 6.0 version goes here
  39.  
  40.         cmp    wp es:[di].List.CurrentNode+2, 0    ;Empty list?
  41.         jne    HasAList
  42.  
  43. ; At this point, the CurrentNode pointer is zero.  This only occurs if the
  44. ; list is empty.
  45. ;
  46. ; Note: Technically, the NIL pointer is 32-bits of zero. However, this
  47. ; package assumes that if the segment is zero, the whole thing is zero.
  48. ; So don't put any nodes into segment zero!
  49.  
  50.         xor    dx, dx                ;Set DX:SI to NIL.
  51.         mov    si, dx
  52.         stc
  53.         jmp    PeekDone
  54.  
  55. ; Return a pointer to the CurrentNode:
  56.  
  57. HasAList:    mov    si, wp es:[di].List.CurrentNode    ;Get ptr to first
  58.         mov    dx, wp es:[di].List.CurrentNode+2 ; item
  59.  
  60.  
  61.         else
  62.  
  63. ; All other assemblers come down here:
  64.  
  65.         cmp    wp es:[di].CurrentNode+2, 0        ;Empty list?
  66.         jne    HasAList
  67.  
  68. ; At this point, the Head pointer is zero.  This only occurs if the
  69. ; list is empty.
  70. ;
  71. ; Note: Technically, the NIL pointer is 32-bits of zero. However, this
  72. ; package assumes that if the segment is zero, the whole thing is zero.
  73. ; So don't put any nodes into segment zero!
  74.  
  75.         xor    dx, dx                ;Set DX:SI to NIL.
  76.         mov    si, dx
  77.         stc
  78.         jmp    PeekDone
  79.  
  80. ; Return a pointer to the first node.
  81.  
  82. HasAList:    mov    si, wp es:[di].CurrentNode      ;Get ptr to first
  83.         mov    dx, wp es:[di].CurrentNode+2    ; item
  84.  
  85.  
  86.         endif
  87.  
  88.         clc
  89. PeekDone:    ret
  90.  
  91. sl_PeekCur    endp
  92.  
  93. stdlib        ends
  94.         end
  95.